package A2020;

import java.util.Scanner;

public class _数字三角形 {

	private static int n;
	private static int[][] m=new int[105][105];
	static int[][] dr= {{1,0},{1,1}};
	private static int sum;
	public static void main(String[] args) {
	Scanner sc=new Scanner(System.in);
	n=sc.nextInt();
	sc.nextLine();
	for (int i = 0; i <n; i++) {
		for (int j = 0; j < i; j++) {
			m[i][j]=sc.nextInt();
		}
	}
		f(0,0,0);
		System.out.println(sum);
	}
	private static void f(int i, int ii,int ans) {
		ans+=m[i][ii];
		if(i>=n) {
			if(Math.abs(i-(2*ii))<=1) {
				sum=Math.max(sum, ans);
			}
			return;
		}
		for (int j = 0; j < 2; j++) {
			f(i+dr[j][0],ii+dr[j][1],ans);
		}
	}

}
